package org.yelongframework.yaml.generator;

import java.io.Writer;
import java.util.Objects;

import org.yaml.snakeyaml.Yaml;
import org.yelongframework.yaml.YamlMap;

/**
 * yaml生成器默认实现
 * 
 * @since 1.0.0
 */
public class DefaultYamlGenerator implements YamlGenerator {

	private final Yaml yaml;

	public DefaultYamlGenerator(Yaml yaml) {
		this.yaml = Objects.requireNonNull(yaml);
	}

	@Override
	public String generate(YamlMap yamlMap) {
		return yaml.dump(yamlMap);
	}

	@Override
	public void generate(YamlMap yamlMap, Writer writer) {
		yaml.dump(yamlMap, writer);
	}

}
